<?php

namespace app\modules\admin\controllers;

use app\models\AttrLinkHotelScenic;
use app\models\HotelScenic;
use yii\web\Controller;
use Overtrue\Pinyin\Pinyin;
use PHPExcel;
use PHPExcel_IOFactory;
use app\extensions\XUtils;
use app\models\Tag;
use app\services\TagService;
/**
 * Default controller for the `admin` module
 */
class DefaultController extends BaseController
{
    public function init()
    {
        parent::init();
    }
    /**
     * Renders the index view for the module
     * @return string
     */
    public function actionIndex()
    {
        $data = [];
        $data['sysName'] = 'XXX管理后台';
        $data['sysVersion'] = 'V1.0';
        $data['hostName'] = $_SERVER['HTTP_HOST'];
        $data['serverSoft'] = $_SERVER['SERVER_SOFTWARE'];
        $data['serverOs'] = PHP_OS;
        $data['phpVersion'] = PHP_VERSION;
        $data['fileupload'] = ini_get('file_uploads') ? ini_get('file_uploads') : '禁止上传';// post_max_size
        $data['postMaxSize'] = ini_get('post_max_size') ? ini_get('post_max_size') : '2M';// post_max_size
        
        //获取系统的内存
        $memory = memory_get_usage();
        $unit=array('b','kb','mb','gb','tb','pb');
        $data['memory'] = @round($memory/pow(1024,($i=floor(log($memory,1024)))),2).' '.$unit[$i];

        return $this->render('index',['data' => $data]);
    }
    /**
     * 访问受限页面
     */
    public function actionForbidden()
    {
        return $this->render('forbidden');
    }
    /**
     * 找不到请求的资源
     */
    public function actionNopage()
    {
        return $this->render('nopage');
    }

    public function actionExecl(){
        $file = dirname(__FILE__) . '/shop.xlsx';
        $PHPExcel = PHPExcel_IOFactory::load($file);
        $productList = $PHPExcel->getSheet(0)->toArray();
        $channelLink = $PHPExcel->getSheet(1)->toArray();
        $channelLinkPM = $PHPExcel->getSheet(2)->toArray();
        $productPackage = $PHPExcel->getSheet(3)->toArray();
        //XUtils::apiResultStandard("1000","操作成功",$productList);
        $attrLinkHotel = array();
        $hotelScenic = new HotelScenic();
        $attrLinkHotelScenic = new AttrLinkHotelScenic();

        XUtils::apiResultStandard("1000","操作成功",$productList);
    }
}
